import Mock from "mockjs";
Mock.Random.extend({
    phone: function() {
        var phonePrefixs = ["132", "135", "189"]; // 自己写前缀哈
        return this.pick(phonePrefixs) + Mock.mock(/\d{8}/); //Number()
    },
});
Mock.Random.extend({
    xh: function() {
        var xhPrefixs = ["2022"]; // 自己写前缀哈
        return this.pick(xhPrefixs) + Mock.mock(/\d{4}/); //Number()
    },
});
// 定义数据类型
let data = Mock.mock({
    // 20条数据
    "data|95": [{
        "num|+1": 1,
        name: "@cname",
        xh: "@xh",
        "sex|1": ["男", "女"],
        // 手机号
        phone: "@phone",
        // 方式
        //时间
        regTime: "@date(2021-MM-dd)",
        userTime: "@natural(0, 100)",
        //商品名称
        allMoney: "@natural(3000, 6000)",
        relax: "@natural(0, 10)",
        //商品地址
        validTime: "@date(2022-MM-dd)",
        flag: "",
    }, ],
});

class stuAccountService {
    getDate() {
        return Promise.resolve({
            data,
        });
    }
    edit(id) {
        let obj = {};
        data.data = data.data.filter((item) => {
            if (item.xh == id) {
                obj = item;
            }
            return data;
        });
        return Promise.resolve(obj);
    }
}

const stuAccount = new stuAccountService();
export default stuAccount;